<template>
<div class="box" v-loading="loading">
    <div v-if="contentText"  class="data-content">
        <el-descriptions class="margin-top" title="裁判文书" :column="1" border>
            <el-descriptions-item>
                <template slot="label"> 文书 </template>
                <el-link :href="contentText.fileUrl" :underline="false" type="primary">{{ contentText.title }}</el-link>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label"> 创建时间 </template>
                {{ contentText.createTime }}
            </el-descriptions-item>

        </el-descriptions>
        <el-link  type="info" :underline="false">*此数据来源于中国裁判文书官方网站</el-link>
    </div>
    <div v-else>
        <div class="nodata">
            <img :src="imgUrl" alt="" />
        </div>
    </div>
</div>
    
</template>

<script>
export default {
    props: {
        companyName: {
            type: String,
            default: "",
        },
        projectId: {
            type: String,
            default: "",
        },
        navName: {
            type: String,
            default: "",
        },
    },
    data: () => ({
        contentText: {},
        imgUrl: require("../../img/wu.png"),
        loading:false
    }),
    methods: {
        //获取企业基本信息
        getQiYeInfo() {
            var that = this;
            this.loading = true
            this.$ajax({
                type: "get",
                url: `${this.$store.state.api.searchUrl}/searchcpws/xhfzjl`,
                data: {
                    corpName: that.companyName,
                    projectId: that.projectId,
                    pagNo: 1,
                },
                callback: function (data, res) {
                    // loading.close()
                    if (data.rows && data.rows.length > 0) {
                        that.contentText = data.rows[0];
                        that.$emit('pushValidNames',that.navName)
                    } else if (data.code == 401006) {
                        ShowMsg("无查询功能VIP服务或VIP服务已过期", "info");
                    }
                    this.loading = false
                },
            });
        },
    },
    watch: {
        companyName() {
            this.getQiYeInfo();
        },
    },
    mounted() {
        this.getQiYeInfo();
    },
};
</script>

<style scoped lang="scss">
.box {
    width: 100%;
    min-height:400px ;
}
.data-content {
    // border-bottom: 1px solid #efefef;
    padding: 10px 15px;
}
.nodata {
    width: 30%;
    margin: 20px auto;
}
</style>
